/*
 * AssignMeterInfoBO.java 
 * 
 * Copyright 2009 Wangfeng Beijing Inc. 
 * All rights reserved. 
 * 
 * Created on 2012-07-06
 */

package com.bjtech.domain.query;

import java.util.Date;
import com.bjtech.web.util.SelectBean;
import org.ssi.web.util.QuerySpecTpl;

/**
 * 功能概述:分配表信息管理 <br>
 * 
 * @author 王峰
 */

public class AssignMeterInfoQuerySpec extends SelectBean {
	/* */
	private Long id;
	/* */
	private Long room_id;
	/* */
	private String serious_num;
	/* */
	private Long sink_id;
	/* */
	private String model;
	/* */
	private Long type;
	/* */
	private Date install_date;
	private Date b_install_date;
	private Date e_install_date;
	/* */
	private String install_man;
	/* */
	private String record_man;
	/* */
	private Long is_normal;
	/* */
	private String soft_version;
	/* */
	private String hard_version;
	/* */
	private String demo;

	@Override
	public void queryParamString() {
		StringBuilder fromPart = new StringBuilder(" where 1=1");

		if (this.isAll != null && this.isAll.intValue() != 1) {
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}

			if (QuerySpecTpl.isValid(room_id)) {
				fromPart.append(" and a.room_id = ");
				fromPart.append(room_id);
			}

			if (QuerySpecTpl.isValid(serious_num)) {
				fromPart.append(" and a.serious_num like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(serious_num);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(sink_id)) {
				fromPart.append(" and a.sink_id = ");
				fromPart.append(sink_id);
			}

			if (QuerySpecTpl.isValid(model)) {
				fromPart.append(" and a.model like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(model);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(type)) {
				fromPart.append(" and a.type = ");
				fromPart.append(type);
			}

			if (QuerySpecTpl.isValid(install_date)) {
				fromPart
						.append(" and str_to_date(a.install_date,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(install_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_install_date)) {
				fromPart
						.append(" and str_to_date(a.install_date,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_install_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_install_date)) {
				fromPart
						.append(" and str_to_date(a.install_date,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_install_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(install_man)) {
				fromPart.append(" and a.install_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(install_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(record_man)) {
				fromPart.append(" and a.record_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(record_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(is_normal)) {
				fromPart.append(" and a.is_normal = ");
				fromPart.append(is_normal);
			}

			if (QuerySpecTpl.isValid(soft_version)) {
				fromPart.append(" and a.soft_version like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(soft_version);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(hard_version)) {
				fromPart.append(" and a.hard_version like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(hard_version);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(demo)) {
				fromPart.append(" and a.demo like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(demo);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(this.direction)
					&& QuerySpecTpl.isValid(this.sort)) {
				fromPart.append(" order by ");
				fromPart.append(this.sort);
				fromPart.append(" ");
				fromPart.append(this.direction);
			} else {
				fromPart.append(" order by ");
				fromPart.append("id");
				fromPart.append(" ");
				fromPart.append("asc");

			}
		}
		super.setQueryString(fromPart.toString());
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getRoom_id() {
		return this.room_id;
	}

	public void setRoom_id(Long room_id) {
		this.room_id = room_id;
	}

	public String getSerious_num() {
		return this.serious_num;
	}

	public void setSerious_num(String serious_num) {
		this.serious_num = serious_num;
	}

	public Long getSink_id() {
		return this.sink_id;
	}

	public void setSink_id(Long sink_id) {
		this.sink_id = sink_id;
	}

	public String getModel() {
		return this.model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public Long getType() {
		return this.type;
	}

	public void setType(Long type) {
		this.type = type;
	}

	public Date getInstall_date() {
		return this.install_date;
	}

	public void setInstall_date(Date install_date) {
		this.install_date = install_date;
	}

	public Date getB_install_date() {
		return this.b_install_date;
	}

	public void setB_install_date(Date b_install_date) {
		this.b_install_date = b_install_date;
	}

	public Date getE_install_date() {
		return this.e_install_date;
	}

	public void setE_install_date(Date e_install_date) {
		this.e_install_date = e_install_date;
	}

	public String getInstall_man() {
		return this.install_man;
	}

	public void setInstall_man(String install_man) {
		this.install_man = install_man;
	}

	public String getRecord_man() {
		return this.record_man;
	}

	public void setRecord_man(String record_man) {
		this.record_man = record_man;
	}

	public Long getIs_normal() {
		return this.is_normal;
	}

	public void setIs_normal(Long is_normal) {
		this.is_normal = is_normal;
	}

	public String getSoft_version() {
		return this.soft_version;
	}

	public void setSoft_version(String soft_version) {
		this.soft_version = soft_version;
	}

	public String getHard_version() {
		return this.hard_version;
	}

	public void setHard_version(String hard_version) {
		this.hard_version = hard_version;
	}

	public String getDemo() {
		return this.demo;
	}

	public void setDemo(String demo) {
		this.demo = demo;
	}
}
